//
//  rongziViewController.m
//  hainingOASystem
//
//  Created by michael on 2017/11/14.
//  Copyright © 2017年 czd. All rights reserved.
//

#import "rongziViewController.h"
@interface rongziViewController ()

@end

@implementation rongziViewController

- (void)viewDidLoad {
    [super viewDidLoad];
        NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:

[UIColor whiteColor],NSForegroundColorAttributeName, nil];
 
[self.navigationController.navigationBar setTitleTextAttributes:attributes];
 self.navigationController.navigationBar.barTintColor = COLORRGB(0x3F51B5);
      self.title = @"融资申请";
    self.view.backgroundColor = [UIColor whiteColor];
if([_type isEqualToString:@"main"]){
    _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth,KScreenHeight-kTopHeight) style:UITableViewStylePlain];


}
else{
    _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth,KScreenHeight-kTopHeight-kTabBarHeight) style:UITableViewStylePlain];
    
}
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

_tableView.dataSource = self;
_tableView.delegate = self;
[self.view addSubview:_tableView];

            [self request];
    // Do any additional setup after loading the view.
}
- (void)request{
[httpTool ZBPostNetDataWith:krzsq withDic:nil andSuccess:^(NSDictionary* dictionary){
 _jyNSarray = [NSMutableArray array];
 _yhNSarray = [NSMutableArray array];
 _xeNSarray = [NSMutableArray array];
 _rzNSarray = [NSMutableArray array];
 _mjNSarray = [NSMutableArray array];
 _llNSarray = [NSMutableArray array];
 
 _jyarray = dictionary[@"methodList"];
 _yharray = dictionary[@"bankList"];
 _xearray = dictionary[@"pettyList"];
 _rzarray = dictionary[@"leaseList"];
 _mjarray = dictionary[@"privateList"];
 _llarray = dictionary[@"interestList"];
 
 for (NSDictionary *dic in _jyarray) {
    [_jyNSarray addObject:dic[@"name"]];
}
for (NSDictionary *dic in _yharray) {
    [_yhNSarray addObject:dic[@"name"]];
}
for (NSDictionary *dic in _xearray) {
    [_xeNSarray addObject:dic[@"name"]];
}
for (NSDictionary *dic in _rzarray) {
    [_rzNSarray addObject:dic[@"name"]];
}
for (NSDictionary *dic in _mjarray) {
    [_mjNSarray addObject:dic[@"name"]];
    [_tableView reloadData];
}
for (NSDictionary *dic in _llarray) {
    [_llNSarray addObject:dic[@"name"]];
}
 
 
 NSLog(@"%@",dictionary);
 }andFailure:^{
 
 }];

}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
}
#pragma mark UITableView dataScource
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
if(indexPath.row ==0){
static NSString *cellid0 = @"cell0";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid0];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     if (!cell) {
             cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid0];
   UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 80, 40)];
  
    label.text = @"*简要用途:";
    label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
      _fanweibox = [[fanweibox alloc]init];
    _fanweibox = [fanweibox checkBoxFootView];
   _fanweibox.frame = CGRectMake(label.right, label.top +10, KScreenWidth-120, 30);
           [cell.contentView addSubview:_fanweibox];
           UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(10, label.bottom, 80, 40)];
  
    label2.text = @"*简要方式";
    label2.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label2];
          _jybutton = [UIButton buttonWithType:UIButtonTypeCustom];
      _jybutton.frame =CGRectMake(label2.right, label.bottom+10 , KScreenWidth-20-80, 30);
          _jybutton.backgroundColor = [UIColor whiteColor];

        [_jybutton.layer setBorderColor:[UIColor blackColor].CGColor];
    [_jybutton.layer setBorderWidth:1];
 [_jybutton.layer setMasksToBounds:YES];
    [_jybutton setTitle:@"选择简要方式" forState:UIControlStateNormal];
    _jybutton.titleLabel.font = [UIFont systemFontOfSize: 14.0];
          [_jybutton setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
        _jybutton.layer.cornerRadius = _jybutton.height/2;
//            _lilvField.layer.cornerRadius=8.0f;
//   _lilvField.layer.masksToBounds=YES;
//    _lilvField.layer.borderColor=[[UIColor grayColor]CGColor];
//    _lilvField.layer.borderWidth= 1.0f;
        [_jybutton addTarget:self action:@selector(jyaction) forControlEvents:UIControlEventTouchUpInside];
                    [cell.contentView addSubview:_jybutton];

         
         
         
   UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(10, label2.bottom, 80, 40)];
    label3.text = @"*融资金额(万元)";
    label3.numberOfLines = 0;
    label3.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label3];
    _rzjeField = [[UITextField alloc]init];
       [_rzjeField setValue:[UIFont boldSystemFontOfSize:12] forKeyPath:@"_placeholderLabel.font"];
       _rzjeField.keyboardType = UIKeyboardTypeNumberPad;
   _rzjeField.placeholder = @"     请输入融资金额";
     [_rzjeField setValue:[UIFont boldSystemFontOfSize:13] forKeyPath:@"_placeholderLabel.font"];
  _rzjeField.frame = CGRectMake(label3.right, label3.top+5, (KScreenWidth-20)-label3.width, 30);
      _rzjeField.delegate = self;
      [_rzjeField setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];
    _rzjeField.layer.cornerRadius=8.0f;
   _rzjeField.layer.masksToBounds=YES;
    _rzjeField.layer.borderColor=[[UIColor grayColor]CGColor];
    _rzjeField.layer.borderWidth= 1.0f;
             [cell.contentView addSubview:_rzjeField];

   UILabel *label4 = [[UILabel alloc]initWithFrame:CGRectMake(10, label3.bottom, 80, 40)];
    label4.text = @"*融资年限(年)";
    label4.numberOfLines = 0;
    label4.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label4];
    _rznxField = [[UITextField alloc]init];
           _rznxField.keyboardType = UIKeyboardTypeNumberPad;

   _rznxField.placeholder = @"     请输入融资年限(年)";
   [_rznxField setValue:[UIFont boldSystemFontOfSize:13] forKeyPath:@"_placeholderLabel.font"];

[_rznxField setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];
  _rznxField.frame = CGRectMake(label4.right, label4.top+5, (KScreenWidth-20)-label3.width, 30);
      _rznxField.delegate = self;
    _rznxField.layer.cornerRadius=8.0f;
   _rznxField.layer.masksToBounds=YES;
    _rznxField.layer.borderColor=[[UIColor grayColor]CGColor];
    _rznxField.layer.borderWidth= 1.0f;
             [cell.contentView addSubview:_rznxField];
 UILabel *label5 = [[UILabel alloc]initWithFrame:CGRectMake(10, label4.bottom, 80, 40)];
 
    label5.text = @"*简要说明";
    label5.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label5];
             _jysmField = [[UITextView alloc]init];
   
  _jysmField.frame = CGRectMake(10, label5.bottom, (KScreenWidth-20),80);
      _jysmField.delegate = self;
    _jysmField.layer.cornerRadius=8.0f;
   _jysmField.layer.masksToBounds=YES;
    _jysmField.layer.borderColor=[[UIColor grayColor]CGColor];
    _jysmField.layer.borderWidth= 1.0f;
             [cell.contentView addSubview:_jysmField];

     //200
     }
return cell;
}if (indexPath.row ==1) {
    static NSString *cellid1 = @"cell1";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid1];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     if (!cell) {
   cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid1];
       UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, KScreenWidth-20, 40)];
  
    label.text = @"*愿意合作的金融机构";
    label.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label];
    
   UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(10, label.bottom, 100, 40)];
    label1.text = @"银行(最多选择三家)";
    label1.numberOfLines = 0;
    label1.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label1];
//      _yhField = [[UITextField alloc]init];
//   _yhField.placeholder = @"请输入融资年限(年)";
//                  [_yhField setValue:[UIFont boldSystemFontOfSize:11] forKeyPath:@"_placeholderLabel.font"];
//
//[_yhField setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];
//  _yhField.frame = CGRectMake(label1.right, label1.top+5, KScreenWidth-20-label1.width, 30);
//      _yhField.delegate = self;
//    _yhField.layer.cornerRadius=8.0f;
//   _yhField.layer.masksToBounds=YES;
//    _yhField.layer.borderColor=[[UIColor grayColor]CGColor];
//    _yhField.layer.borderWidth= 1.0f;
//  [cell.contentView addSubview:_yhField];
     _yhbutton = [UIButton buttonWithType:UIButtonTypeCustom];
      _yhbutton.frame =CGRectMake(label1.right, label1.top+5, KScreenWidth-20-label1.width, 30);
          _yhbutton.backgroundColor = [UIColor whiteColor];

        [_yhbutton.layer setBorderColor:[UIColor blackColor].CGColor];
    [_yhbutton.layer setBorderWidth:1];
 [_yhbutton.layer setMasksToBounds:YES];
    [_yhbutton setTitle:@"选择银行" forState:UIControlStateNormal];
    _yhbutton.titleLabel.font = [UIFont systemFontOfSize: 14.0];
          [_yhbutton setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
        _yhbutton.layer.cornerRadius = _yhbutton.height/2;

        [_yhbutton addTarget:self action:@selector(yhaction) forControlEvents:UIControlEventTouchUpInside];
                    [cell.contentView addSubview:_yhbutton];
     UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(10, label1.bottom, 100, 40)];
    label2.text = @"小额贷款公司";
    label2.numberOfLines = 0;
    label2.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label2];
          _xebutton = [UIButton buttonWithType:UIButtonTypeCustom];
      _xebutton.frame =CGRectMake(label2.right, label2.top+5, KScreenWidth-20-label2.width, 30);
          _xebutton.backgroundColor = [UIColor whiteColor];

        [_xebutton.layer setBorderColor:[UIColor blackColor].CGColor];
    [_xebutton.layer setBorderWidth:1];
 [_xebutton.layer setMasksToBounds:YES];
    [_xebutton setTitle:@"选择小额贷款公司" forState:UIControlStateNormal];
    _xebutton.titleLabel.font = [UIFont systemFontOfSize: 14.0];
          [_xebutton setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
        _xebutton.layer.cornerRadius = _xebutton.height/2;

        [_xebutton addTarget:self action:@selector(xeaction) forControlEvents:UIControlEventTouchUpInside];
                    [cell.contentView addSubview:_xebutton];
  
   UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(10, label2.bottom, 100, 40)];
    label3.text = @"融资贷款公司";
    label3.numberOfLines = 0;
    label3.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label3];
     _rzbutton = [UIButton buttonWithType:UIButtonTypeCustom];
      _rzbutton.frame =CGRectMake(label3.right, label3.top+5, KScreenWidth-20-label3.width, 30);
          _rzbutton.backgroundColor = [UIColor whiteColor];

        [_rzbutton.layer setBorderColor:[UIColor blackColor].CGColor];
    [_rzbutton.layer setBorderWidth:1];
 [_rzbutton.layer setMasksToBounds:YES];
    [_rzbutton setTitle:@"选择融资贷款公司" forState:UIControlStateNormal];
    _rzbutton.titleLabel.font = [UIFont systemFontOfSize: 14.0];
          [_rzbutton setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
        _rzbutton.layer.cornerRadius = _rzbutton.height/2;

        [_rzbutton addTarget:self action:@selector(rzaction) forControlEvents:UIControlEventTouchUpInside];
                    [cell.contentView addSubview:_rzbutton];
  
   UILabel *label4 = [[UILabel alloc]initWithFrame:CGRectMake(10, label3.bottom, 100, 40)];
    label4.text = @"民间融资机构";
    label4.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label4];
      _mjbutton
       = [UIButton buttonWithType:UIButtonTypeCustom];
      _mjbutton.frame =CGRectMake(label4.right, label4.top+5, KScreenWidth-20-label4.width, 30);
          _mjbutton.backgroundColor = [UIColor whiteColor];

        [_mjbutton.layer setBorderColor:[UIColor blackColor].CGColor];
    [_mjbutton.layer setBorderWidth:1];
 [_mjbutton.layer setMasksToBounds:YES];
    [_mjbutton setTitle:@"选择民间融资机构" forState:UIControlStateNormal];
    _mjbutton.titleLabel.font = [UIFont systemFontOfSize: 14.0];
          [_mjbutton setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
        _mjbutton.layer.cornerRadius = _mjbutton.height/2;

        [_mjbutton addTarget:self action:@selector(mjaction) forControlEvents:UIControlEventTouchUpInside];
                    [cell.contentView addSubview:_mjbutton];
    //180 = 40*4=20
         
   }return cell;
}
if (indexPath.row ==2) {
    
    static NSString *cellid2 = @"cell2";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid2];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     if (!cell) {
   cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid2];
      UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 100, 40)];
      label1.numberOfLines = 0;
    label1.text = @"*可接受融资成本(年华利率)";
    label1.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label1];
         _llbutton
       = [UIButton buttonWithType:UIButtonTypeCustom];
      _llbutton.frame =CGRectMake(label1.right, label1.top+5, KScreenWidth-20-label1.width, 30);
          _llbutton.backgroundColor = [UIColor whiteColor];

        [_llbutton.layer setBorderColor:[UIColor blackColor].CGColor];
    [_llbutton.layer setBorderWidth:1];
 [_llbutton.layer setMasksToBounds:YES];
    [_llbutton setTitle:@"选择年华利率" forState:UIControlStateNormal];
    _llbutton.titleLabel.font = [UIFont systemFontOfSize: 14.0];
          [_llbutton setTitleColor:[UIColor blackColor]forState:UIControlStateNormal];
        _llbutton.layer.cornerRadius = _llbutton.height/2;

        [_llbutton addTarget:self action:@selector(llaction) forControlEvents:UIControlEventTouchUpInside];
                    [cell.contentView addSubview:_llbutton];
    UILabel *label5 = [[UILabel alloc]initWithFrame:CGRectMake(10, label1.bottom, KScreenWidth-20, 40)];
 
    label5.text = @"抵押或质押物描述(若融资方式为抵押或质押,此项必填):";
    label5.numberOfLines = 0;
    label5.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label5];
             _dyField = [[UITextView alloc]init];
   
  _dyField.frame = CGRectMake(10, label5.bottom, (KScreenWidth-20), 80);
      _dyField.delegate = self;
    _dyField.layer.cornerRadius=8.0f;
   _dyField.layer.masksToBounds=YES;
    _dyField.layer.borderColor=[[UIColor grayColor]CGColor];
    _dyField.layer.borderWidth= 1.0f;
             [cell.contentView addSubview:_dyField];
   //160
     }
    return cell;
}
else{

 static NSString *cellid3 = @"cell3";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellid3];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     if (!cell) {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid3];

      UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, 80, 40)];
    label1.text = @"联系人";
    label1.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label1];
    _lxrField = [[UITextField alloc]init];
   _lxrField.placeholder = @"     不填默认为自己";
         [_lxrField setValue:[UIFont boldSystemFontOfSize:13] forKeyPath:@"_placeholderLabel.font"];

  _lxrField.frame = CGRectMake(label1.right, label1.top+5, (KScreenWidth-20)-label1.width, 30);
      _lxrField.delegate = self;
      [_lxrField setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];
    _lxrField.layer.cornerRadius=8.0f;
   _lxrField.layer.masksToBounds=YES;
    _lxrField.layer.borderColor=[[UIColor grayColor]CGColor];
    _lxrField.layer.borderWidth= 1.0f;
             [cell.contentView addSubview:_lxrField];

   UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(10,label1.bottom, 80, 40)];
    label2.text = @"职务";
    label2.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label2];
    _zwField = [[UITextField alloc]init];
   _zwField.placeholder = @"     请输入职务名称";
[_zwField setValue:[UIColor grayColor]
 forKeyPath:@"_placeholderLabel.textColor"];
       [_zwField setValue:[UIFont boldSystemFontOfSize:13] forKeyPath:@"_placeholderLabel.font"];

  _zwField.frame = CGRectMake(label2.right, label2.top+5, (KScreenWidth-20)-label2.width, 30);
      _zwField.delegate = self;
    _zwField.layer.cornerRadius=8.0f;
   _zwField.layer.masksToBounds=YES;
    _zwField.layer.borderColor=[[UIColor grayColor]CGColor];
    _zwField.layer.borderWidth= 1.0f;
             [cell.contentView addSubview:_zwField];
         
                   UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(10, label2.bottom, 80, 40)];
    label3.text = @"固定电话";
    label3.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label3];
    _lxrField = [[UITextField alloc]init];
   _lxrField.placeholder = @"     请输入电话号码";
      [_lxrField setValue:[UIFont boldSystemFontOfSize:13] forKeyPath:@"_placeholderLabel.font"];
       _lxrField.keyboardType = UIKeyboardTypeNumberPad;

  _lxrField.frame = CGRectMake(label3.right, label3.top+5, (KScreenWidth-20)-label3.width, 30);
      _lxrField.delegate = self;
      [_lxrField setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];
    _lxrField.layer.cornerRadius=8.0f;
   _lxrField.layer.masksToBounds=YES;
    _lxrField.layer.borderColor=[[UIColor grayColor]CGColor];
    _lxrField.layer.borderWidth= 1.0f;
             [cell.contentView addSubview:_lxrField];

   UILabel *label4 = [[UILabel alloc]initWithFrame:CGRectMake(10,label3.bottom, 80, 40)];
    label4.text = @"联系人手机";
    label4.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label4];
    _phoneField = [[UITextField alloc]init];
       _phoneField.keyboardType = UIKeyboardTypeNumberPad;

   _phoneField.placeholder = @"     请输入电话号码";
      [_phoneField setValue:[UIFont boldSystemFontOfSize:13] forKeyPath:@"_placeholderLabel.font"];

[_phoneField setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];
  _phoneField.frame = CGRectMake(label4.right, label4.top+5, (KScreenWidth-20)-label2.width, 30);
      _phoneField.delegate = self;
    _phoneField.layer.cornerRadius=8.0f;
   _phoneField.layer.masksToBounds=YES;
    _phoneField.layer.borderColor=[[UIColor grayColor]CGColor];
    _phoneField.layer.borderWidth= 1.0f;
             [cell.contentView addSubview:_phoneField];
   
     UILabel *label5 = [[UILabel alloc]initWithFrame:CGRectMake(10, label4.bottom, 80, 40)];
 
    label5.text = @"补充说明";
    label5.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label5];
             _smField = [[UITextView alloc]init];
   
  _smField.frame = CGRectMake(10, label5.bottom, (KScreenWidth-20), 80);
      _smField.delegate = self;
    _smField.layer.cornerRadius=8.0f;
   _smField.layer.masksToBounds=YES;
    _smField.layer.borderColor=[[UIColor grayColor]CGColor];
    _smField.layer.borderWidth= 1.0f;
             [cell.contentView addSubview:_smField];
                UILabel *label6 = [[UILabel alloc]initWithFrame:CGRectMake(10, _smField.bottom, 80, 40)];
 
    label6.text = @"验证码";
    label6.font = [UIFont systemFontOfSize:14];
    [cell.contentView addSubview:label6];
    _yzField =[[UITextField alloc]init];
      _yzField.frame = CGRectMake(label6.right, label6.top+5, (KScreenWidth-20)/2-label6.width, 30);
               _yzField.placeholder = @"请输入验证码";
               [_yzField setValue:[UIFont boldSystemFontOfSize:12] forKeyPath:@"_placeholderLabel.font"];

[_yzField setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];

      _yzField.delegate = self;
    _yzField.layer.cornerRadius=8.0f;
   _yzField.layer.masksToBounds=YES;
    _yzField.layer.borderColor=[[UIColor grayColor]CGColor];
    _yzField.layer.borderWidth= 1.0f;
             [cell.contentView addSubview:_yzField];
      _testView = [[NNValidationView alloc] initWithFrame:CGRectMake( _yzField.right+20, _yzField.top, (KScreenWidth-20)/2-60 , 30) andCharCount:4 andLineCount:8];
    [cell.contentView addSubview:_testView];
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
      button.frame = CGRectMake((KScreenWidth-100)/2, label6.bottom+10, 100, 40);
          button.backgroundColor = [UIColor blueColor];

        [button.layer setBorderColor:[UIColor blueColor].CGColor];
    [button.layer setBorderWidth:1];
 [button.layer setMasksToBounds:YES];
    [button setTitle:@"确定" forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize: 14.0];
          [button setTitleColor:[UIColor whiteColor]forState:UIControlStateNormal];
        button.layer.cornerRadius = button.height/2;
                [button addTarget:self action:@selector(action) forControlEvents:UIControlEventTouchUpInside];

            [cell.contentView addSubview:button];

    
     }
return cell;
}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return  4;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row == 0){
return 240+40;
}if (indexPath.row == 1){
return 200;
}if (indexPath.row == 2){
return 160;
}else{
return 300+80;
}


}
- (void)action{
  NSString *name = [[NSUserDefaults standardUserDefaults] objectForKey:@"userId"];
                NSString *password = [[NSUserDefaults standardUserDefaults] objectForKey:@"password"];

_url = [[NSString alloc]initWithFormat:@"%@%@&password=%@",krzsqtj,name,password];
if ([_fanweibox.orderString isEqualToString:@"0"]) {
    _yongtu = @"1";
}else{
    _yongtu = @"2";
}

    NSString *yanzheng = _yzField.text;
    yanzheng = [yanzheng uppercaseString];//转成大写
NSString *rzjestring=[_rzjeField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *rznxstring=[_rznxField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *jysmstring=[_jysmField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *dystring=[_dyField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

if ([rzjestring isEqualToString:@""]|| rzjestring.length == 0){
        [self.view makeToast:@"对不起，融资金额为空"];
}
else if ([rzjestring intValue]>=1000) {
            [self.view makeToast:@"对不起，融资金额不能超过1000"];

}else if ([rznxstring intValue]>=30) {
            [self.view makeToast:@"对不起，融资金额不能超过30"];

}



else if ([rznxstring isEqualToString:@""]|| rznxstring.length == 0){
        [self.view makeToast:@"对不起，融资年限为空"];
}else if ([jysmstring isEqualToString:@""]|| jysmstring.length == 0){
        [self.view makeToast:@"对不起，简要说明为空"];
}else if ([_jystring containsString:@"抵押"]||[_jystring containsString:@"质押"] ){
if ([dystring isEqualToString:@""]|| dystring.length == 0) {
            [self.view makeToast:@"对不起，抵押或物质描述为空"];

}
}else if(![_jyselarray isKindOfClass:[NSArray class]] && _jyselarray.count == 0){
        [self.view makeToast:@"对不起，简要方式为空"];

}else if((![_yhselarray isKindOfClass:[NSArray class]] && _yhselarray.count == 0) &&(![_xeselarray isKindOfClass:[NSArray class]] && _xeselarray.count == 0)&&(![_rzselarray isKindOfClass:[NSArray class]] && _rzselarray.count == 0)&&(![_mjselarray isKindOfClass:[NSArray class]] && _mjselarray.count == 0)){
        [self.view makeToast:@"对不起，愿意合作的金融机构为空"];

}else if(![_llselarray isKindOfClass:[NSArray class]] && _llselarray.count == 0){
        [self.view makeToast:@"对不起，年华利率为空"];

}else if (![yanzheng isEqualToString:_testView.charString]){
        [self.view makeToast:@"对不起，验证码错误!"];
        CAKeyframeAnimation *anim = [CAKeyframeAnimation animationWithKeyPath:@"transform.translation.x"];
        anim.repeatCount = 1;
        anim.values = @[@-10,@10,@-10];

        [_testView.layer addAnimation:anim forKey:nil];
            _yzField.text = nil;
        [_yzField becomeFirstResponder];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"changePic" object:nil];

    }
//验证码

//     if ([yanzheng isEqualToString:_testView.charString]) {
//        NSLog(@"正确");
//        [_yzField resignFirstResponder];
//
//    }else
//    {
//        NSLog(@"错误");
//        CAKeyframeAnimation *anim = [CAKeyframeAnimation animationWithKeyPath:@"transform.translation.x"];
//        anim.repeatCount = 1;
//        anim.values = @[@-10,@10,@-10];
//
//        [_testView.layer addAnimation:anim forKey:nil];
//            _yzField.text = nil;
//        [_yzField becomeFirstResponder];
//        [[NSNotificationCenter defaultCenter] postNotificationName:@"changePic" object:nil];
//
//    }

else{
_url = [NSString stringWithFormat:@"%@&finace.f_use=%@",_url,_yongtu];//简要用途

NSMutableArray *upjyarray = [NSMutableArray array];
if(_jyselarray.count != 0){
for (NSString *string in _jyselarray) {
    for (NSDictionary *dic in _jyarray) {
    if ([string isEqualToString:dic[@"name"]]) {
    [upjyarray addObject:dic[@"id"]];
}
}
}
}
NSString *jystring = [upjyarray componentsJoinedByString:@","];

_url = [NSString stringWithFormat:@"%@&finace.way=%@",_url,jystring];//简要方式

NSMutableArray *upyharray = [NSMutableArray array];
if(_yhselarray.count != 0){
for (NSString *string in _yhselarray) {
    for (NSDictionary *dic in _yharray) {
    if ([string isEqualToString:dic[@"name"]]) {
    [upyharray addObject:dic[@"id"]];
}
}
}
}
NSString *hystring = [upyharray componentsJoinedByString:@","];

_url = [NSString stringWithFormat:@"%@&bank=%@",_url,hystring];//银行

NSMutableArray *upxearray = [NSMutableArray array];
if(_xeselarray.count != 0){
for (NSString *string in _xeselarray) {
    for (NSDictionary *dic in _xearray) {
    if ([string isEqualToString:dic[@"name"]]) {
    [upxearray addObject:dic[@"id"]];
}
}
}
}
NSString *xestring = [upxearray componentsJoinedByString:@","];

_url = [NSString stringWithFormat:@"%@&petty=%@",_url,xestring];//小额银行

NSMutableArray *upmjarray = [NSMutableArray array];
if(_mjselarray.count != 0){
for (NSString *string in _mjselarray) {
    for (NSDictionary *dic in _mjarray) {
    if ([string isEqualToString:dic[@"name"]]) {
    [upmjarray addObject:dic[@"id"]];
}
}
}
}
NSString *mjstring = [upmjarray componentsJoinedByString:@","];

_url = [NSString stringWithFormat:@"%@&private=%@",_url,mjstring];//民间银行

NSMutableArray *uprzarray = [NSMutableArray array];
if(_rzselarray.count != 0){
for (NSString *string in _rzselarray) {
    for (NSDictionary *dic in _rzarray) {
    if ([string isEqualToString:dic[@"name"]]) {
    [uprzarray addObject:dic[@"id"]];
}
}
}
}
NSString *rzstring = [uprzarray componentsJoinedByString:@","];

_url = [NSString stringWithFormat:@"%@&lease=%@",_url,rzstring];//融资银行

NSMutableArray *upllarray = [NSMutableArray array];
if(_llselarray.count != 0){
for (NSString *string in _llselarray) {
    for (NSDictionary *dic in _llarray) {
    if ([string isEqualToString:dic[@"name"]]) {
    [upllarray addObject:dic[@"id"]];
}
}
}
}
NSString *llstring = [upllarray componentsJoinedByString:@","];

_url = [NSString stringWithFormat:@"%@&finace.rate=%@",_url,llstring];//利率

_url = [NSString stringWithFormat:@"%@&finace.amount=%@",_url,_rzjeField.text];//融资金额
_url = [NSString stringWithFormat:@"%@&finace.limit=%@",_url,_rznxField.text];//融资年限
    NSString *jysmStr=[self URLEncodedString:_jysmField.text];

_url = [NSString stringWithFormat:@"%@&finace.b_description=%@",_url,jysmStr];//简要说明
NSString *lxrestring=[_lxrField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *zwstring=[_zwField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *gdstring=[_gdField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *phonestring=[_phoneField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *smstring=[_smField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];



if (lxrestring.length>0){
    NSString *lxrStr=[self URLEncodedString:lxrestring];

_url = [NSString stringWithFormat:@"%@&finace.linkman=%@",_url,lxrStr];
}else if (zwstring.length>0){
    NSString *zwStr=[self URLEncodedString:zwstring];

_url = [NSString stringWithFormat:@"%@&finace.position=%@",_url,zwStr];
}else if (gdstring.length>0){
_url = [NSString stringWithFormat:@"%@&finace.telephone=%@",_url,gdstring];
}else if (phonestring.length>0){
_url = [NSString stringWithFormat:@"%@&finace.phone=%@",_url,phonestring];
}else if (smstring.length>0){
    NSString *smStr=[self URLEncodedString:smstring];

_url = [NSString stringWithFormat:@"%@&finace.s_description=%@",_url,smStr];
}else if (dystring.length>0){
    NSString *dyStr=[self URLEncodedString:dystring];

_url = [NSString stringWithFormat:@"%@&finace.m_description=%@",_url,dyStr];
}

//_url = [_url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
 [httpTool ZBPostNetDataWith:_url withDic:nil andSuccess:^(NSDictionary* dictionary){
 if ([[NSString stringWithFormat:@"%@",dictionary[@"success"]]isEqualToString:@"true"]) {
         [self.view makeToast:@"提交成功!"];

 [self viewDidLoad];
}

 }andFailure:^{
        [self.view makeToast:@"对不起，提交失败"];

 }];


}
}
-(NSString *)URLEncodedString:(NSString *)str
{
    NSString *encodedString = (NSString *)
    CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
                                                              (CFStringRef)str,
                                                              NULL,
                                                              (CFStringRef)@"!*'();:@&=+$,/?%#[]",
                                                              kCFStringEncodingUTF8));
    
    return encodedString;
}
- (void)jyaction{
[self.view endEditing:YES];

    [EYTagPopupView popViewWithTitle:@"选择简要方式"
                                tags:_jyNSarray
                                 selectTags:_jyselarray
                                type:EYTagPopupView_Type_Multi_Selected
                         cancelBlock:^{
                         } confirmBlock:^(UIView *view, NSArray *tags) {
                         if(tags.count==0){
                                                                           _jyselarray = tags;
                             [_jybutton setTitle:@"选择简要方式" forState:UIControlStateNormal];

                         
                         }else{
                                                  _jyselarray = tags;
                             NSLog(@"tags:   %@",tags);
                             NSString *string = [_jyselarray componentsJoinedByString:@","];
                             [_jybutton setTitle:string forState:UIControlStateNormal];
                         }
                         } dismissBlock:^{
                         }];
}
- (void)yhaction{
[self.view endEditing:YES];

    [EYTagPopupView popViewWithTitle:@"选择银行"
                                tags:_yhNSarray
                                 selectTags:_yhselarray
                                type:EYTagPopupView_Type_Multi_Selected
                         cancelBlock:^{
                             
                         
                         } confirmBlock:^(UIView *view, NSArray *tags) {
                         
                           if(tags.count==0){
           _yhselarray = tags;
    [_yhbutton setTitle:@"选择银行" forState:UIControlStateNormal];
                    }else{
                           
                         _yhselarray = tags;
                         if(_yhselarray.count>3){
                             [self.view makeToast:@"对不起，银行最多选择三家"];
                         
                         }else{
                             NSLog(@"tags:   %@",tags);
                             NSString *string = [_yhselarray componentsJoinedByString:@","];
                             [_yhbutton setTitle:string forState:UIControlStateNormal];
                             [_tableView reloadData];
                             }
                             }
                         } dismissBlock:^{
                         
                         
                         }];
}
- (void)xeaction{
[self.view endEditing:YES];

    [EYTagPopupView popViewWithTitle:@"选择小额贷款公司"
                                tags:_xeNSarray
                                 selectTags:_xeselarray
                                type:EYTagPopupView_Type_Multi_Selected
                         cancelBlock:^{
                         } confirmBlock:^(UIView *view, NSArray *tags) {
                           if(tags.count==0){
                                                    _xeselarray = tags;

                  [_xebutton setTitle:@"选择小额贷款公司" forState:UIControlStateNormal];

                           
                           }else{
                         _xeselarray = tags;
                             NSLog(@"tags:   %@",tags);
                             NSString *string = [_xeselarray componentsJoinedByString:@","];
                             [_xebutton setTitle:string forState:UIControlStateNormal];
                          }
                         } dismissBlock:^{
                         }];
}
- (void)rzaction{
[self.view endEditing:YES];

    [EYTagPopupView popViewWithTitle:@"选择融资贷款公司"
                                tags:_rzNSarray
                                 selectTags:_rzselarray
                                type:EYTagPopupView_Type_Multi_Selected
                         cancelBlock:^{
                         } confirmBlock:^(UIView *view, NSArray *tags) {
                           if(tags.count==0){
                                                _rzselarray = tags;
                             [_rzbutton setTitle:@"选择融资贷款公司" forState:UIControlStateNormal];

                           
                           
                           }else{
                         _rzselarray = tags;
                             NSLog(@"tags:   %@",tags);
                             NSString *string = [_rzselarray componentsJoinedByString:@","];
                             [_rzbutton setTitle:string forState:UIControlStateNormal];
                         }
                         } dismissBlock:^{
                         }];
}
- (void)mjaction{[self.view endEditing:YES];

    [EYTagPopupView popViewWithTitle:@"选择民间融资机构"
                                tags:_mjNSarray
                                 selectTags:_mjselarray
                                type:EYTagPopupView_Type_Multi_Selected
                         cancelBlock:^{
                         } confirmBlock:^(UIView *view, NSArray *tags) {
                          if(tags.count==0){
                                                  _mjselarray = tags;
                             [_mjbutton setTitle:@"选择民间融资机构" forState:UIControlStateNormal];

                          }else{
                         _mjselarray = tags;
                             NSLog(@"tags:   %@",tags);
                             NSString *string = [_mjselarray componentsJoinedByString:@","];
                             [_mjbutton setTitle:string forState:UIControlStateNormal];
                           }
                         } dismissBlock:^{
                         }];
}
- (void)llaction{[self.view endEditing:YES];

    [EYTagPopupView popViewWithTitle:@"选择年华利率"
                                tags:_llNSarray
                                 selectTags:_jyselarray
                                type:EYTagPopupView_Type_Multi_Selected
                         cancelBlock:^{
                         } confirmBlock:^(UIView *view, NSArray *tags) {
                           if(tags.count==0){
                              _llselarray = tags;
                                 [_llbutton setTitle:@"选择年华利率" forState:UIControlStateNormal];
                           }else{
                         _llselarray = tags;
                             NSLog(@"tags:   %@",tags);
                             NSString *string = [_llselarray componentsJoinedByString:@","];
                          
                            }
                         } dismissBlock:^{
                         }];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
